<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="*|/"><xsl:apply-templates/></xsl:template>

<xsl:template match="text()|@*"><xsl:value-of select="."/></xsl:template>

<xsl:template match='nbsp' name='nbsp'>
<xsl:text disable-output-escaping='yes'>&amp;nbsp;</xsl:text>
</xsl:template>

<xsl:include href='../xsl.include.main.xsl'/>

<xsl:template name="im.mailbox.page">
   <xsl:param name="page"/>
   <xsl:param name="nrpages"/>
   <xsl:param name="counter"/>

  <xsl:if test='$nrpages&gt;0'>

      <xsl:choose>
         <xsl:when test='$page &gt; 1 and $counter = 1'>
            <a class="body_10px_red" href="?folder={/mailbox/@name}&amp;page={-1+$page}">prev</a>
         </xsl:when>    
         <xsl:when test='$page = 1 and $counter = 1'>
            <font class="fakeA">prev</font>
         </xsl:when>    
      </xsl:choose>

      <xsl:choose>
         <xsl:when test='$page != $counter'>
            <a style="padding:4px;" class="body_10px_red" href="?folder={/mailbox/@name}&amp;page={$counter}"><xsl:value-of select="$counter"/></a>
         </xsl:when>    
         <xsl:when test='$page = $counter'>
            <font style="padding:4px;" class="fakeA"><xsl:value-of select="$counter"/></font>
         </xsl:when>    
      </xsl:choose>

      <xsl:choose>
         <xsl:when test='floor($counter div 15) = ($counter div 15)'>
            <br/>
         </xsl:when>    
      </xsl:choose>

      <xsl:choose>
         <xsl:when test='$counter = $nrpages and $page != $nrpages'>
            <a class="body_10px_red" href="?folder={/mailbox/@name}&amp;page={1+$page}">next</a>
         </xsl:when>    
         <xsl:when test='$counter = $nrpages and $page = $nrpages'>
            <font class="fakeA">next</font>
         </xsl:when>    
      </xsl:choose>

		<xsl:choose>
			<xsl:when test='$counter &gt;= $nrpages'>
			</xsl:when>
			<xsl:when test='$counter &gt; 0'>
				<xsl:call-template name="im.mailbox.page">
					<xsl:with-param name="page" 		select="$page"/>
					<xsl:with-param name="nrpages" 	select="$nrpages"/>
					<xsl:with-param name="counter" 	select="1+$counter"/>
				</xsl:call-template>
			</xsl:when>
		</xsl:choose>

  </xsl:if>

</xsl:template>

<xsl:template name="substring-before-last">
  <xsl:param name="string" />
  <xsl:choose>
    <xsl:when test="contains($string, ' ')">
    	<xsl:value-of select="substring-before($string, ' ')"/>
    	<xsl:if test="contains(substring-after($string, ' '), ' ')">
			&#32;
			<xsl:call-template name="substring-before-last">
			  <xsl:with-param name="string"
				 select="substring-after($string, ' ')" />
			</xsl:call-template>
    	</xsl:if>
    </xsl:when>
    <xsl:otherwise>
	    <xsl:value-of select="$string" />
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template match="subject">
		<xsl:choose>
			<xsl:when test='string-length(.) &gt; 30'>
				<xsl:call-template name="substring-before-last">
					<xsl:with-param name="string" select="substring(normalize-space(.),1,30)"/>
				</xsl:call-template>...
			</xsl:when>
			<xsl:when test='string-length(.) = 0'>
			(nessun oggetto)
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="."/>
			</xsl:otherwise>
		</xsl:choose>
</xsl:template>

<xsl:template match="mailbox">

<TABLE class="body" onLoad="javascript:uncheckAll();" cellSpacing="0" cellPadding="0" border="0" width="100%">
<form name="mailbox" method="post" action="{@thisPage}" onSubmit="javascript:return confirmDeleteAll();">
<input type="hidden" name="FORM_ID" value="mailbox"></input>
	<TBODY>
		<TR>
			<TD width="8"><IMG height="8" src="/imgs/pvts/box-tl.gif" width="8" border="0"/></TD>
			<TD width="1%" colspan="3" background="/imgs/pvts/box-t-back.gif"  bgcolor="white"><IMG height="8" src="/imgs/pvts/box-t.gif" width="10" border="0"/></TD>
			<TD width="1%" colspan="3" background="/imgs/pvts/box-t-back.gif"  bgcolor="white"><IMG height="8" src="/imgs/pvts/box-t.gif" width="10" border="0"/></TD>
			<TD width="8"><IMG height="8" src="/imgs/pvts/box-tr.gif" width="8" border="0"/></TD>
		</TR>
		<TR vAlign="top">
			<TD width="8" background="/imgs/pvts/box-l-back.gif" bgcolor="white"></TD>
			<TD width="100%" colspan="6" align="left" style="padding:2px; padding-top:5px; padding-bottom:5px;" bgcolor="white">
				<div style="float:right;">
				<input style="margin-bottom:5px; border: 1px solid #555555; font-size:.9em;" type="SUBMIT" name="DELETE" value="Cancella"></input>
				<a style="margin-left:2px;" href="javascript:checkAll();"><img border="0" src="/imgs/mb/check.gif"/></a>
				<a style="margin-left:5px;" href="javascript:uncheckAll();"><img border="0" src="/imgs/mb/uncheck.gif"/></a>
				</div>
				Cartella <b><xsl:value-of select="@name"/></b> (<xsl:value-of select="@totmsg"/> messaggi)<div style="font-size:.8em;color:#666666;">Quota utilizzata <xsl:value-of select="floor(@used div 1024)"/> MB (<b><xsl:value-of select="floor(100 * (@used div @total))"/></b>%) di <xsl:value-of select="floor(@total div 1024)"/> MB disponibili.</div>
			</TD>
			<TD width="8" background="/imgs/pvts/box-r.gif" bgcolor="white"><IMG height="10" src="/imgs/pvts/box-r.gif" width="8" border="0"/></TD>
		</TR>

		<TR vAlign="top">
			<TD width="8" background="/imgs/pvts/box-l-back.gif" bgcolor="white"></TD>
			<TD width="1%" align="left" style="padding:2px; border-bottom: 1px solid #EBE9E4;" bgcolor="white">&#160;</TD>
			<TD width="25px" height="35px" align="left" valign="bottom" style="padding-top:5px; padding:2px; border-bottom: 1px solid #EBE9E4;" bgcolor="white">
				<xsl:choose>
					<xsl:when test='/mailbox/@name="INBOX.Sent" or /mailbox/@name="INBOX.Drafts"'>
						<b>A</b>
					</xsl:when>
					<xsl:otherwise>
						<b>Da</b>
					</xsl:otherwise>
				</xsl:choose>
			</TD>
			<TD width="1%" align="left" style="padding:2px; border-bottom: 1px solid #EBE9E4;" bgcolor="white">&#160;</TD>
			<TD align="left" valign="bottom" style="padding:2px; border-bottom: 1px solid #EBE9E4;" bgcolor="white">
				<b>Oggetto</b>
			</TD>
			<TD width="1%" align="left" valign="bottom" style="padding:2px; border-bottom: 1px solid #EBE9E4;" bgcolor="white">
				<b>Data</b>
			</TD>
			<TD align="right" valign="bottom" style="padding:2px; border-bottom: 1px solid #EBE9E4;" bgcolor="white">
				<b>Size</b>
			</TD>

			<TD width="8" background="/imgs/pvts/box-r.gif" bgcolor="white"><IMG height="10" src="/imgs/pvts/box-r.gif" width="8" border="0"/></TD>
		</TR>

<xsl:for-each select="message">

<xsl:choose>
	<xsl:when test='/mailbox/@itype &gt; 2'>

		<TR vAlign="top">
			<TD width="8" background="/imgs/pvts/box-l-back.gif" bgcolor="white"></TD>
			<TD width="1%" align="left" style="padding:2px; border-bottom: 1px solid #EBE9E4;" bgcolor="white">
				<input type="checkbox" name="deleteList" value="{@msgid}"/>
			</TD>
			<TD width="25px" height="35px" align="left" style="padding-top:5px; padding:2px; border-bottom: 1px solid #EBE9E4;" bgcolor="white">
				<xsl:choose>
					<xsl:when test='/mailbox/@name="INBOX.Sent" or /mailbox/@name="INBOX.Drafts"'>
						<xsl:choose>
							<xsl:when test='to/contact/@userid'>
								<nobr>
								<xsl:call-template name="user">
									<xsl:with-param name="status" select="to/contact/@status"/>
									<xsl:with-param name="sexid" select="to/contact/@sexid"/>
									<xsl:with-param name="certified" select="to/contact/@certified"/>
									<xsl:with-param name="userid" select="to/contact/@userid"/>
									<xsl:with-param name="nick" select="to/contact/@nick"/>
								</xsl:call-template>
								</nobr>
							</xsl:when>
							<xsl:otherwise>
								<nobr><xsl:value-of select="to/contact/@name"/></nobr><br/><span style="font-size:8pt;">&lt;<xsl:value-of select="to/contact/@email"/>&gt;</span>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:when>
					<xsl:otherwise>
						<xsl:choose>
							<xsl:when test='from/contact/@userid'>
								<nobr>
								<xsl:call-template name="user">
									<xsl:with-param name="status" select="from/contact/@status"/>
									<xsl:with-param name="sexid" select="from/contact/@sexid"/>
									<xsl:with-param name="certified" select="from/contact/@certified"/>
									<xsl:with-param name="userid" select="from/contact/@userid"/>
									<xsl:with-param name="nick" select="from/contact/@nick"/>
								</xsl:call-template>
								</nobr>
							</xsl:when>
							<xsl:otherwise>

								<xsl:choose>
									<xsl:when test='string-length(from/contact/@name) &gt; 0'>
										<nobr><xsl:value-of select="from/contact/@name"/></nobr>
									</xsl:when>
									<xsl:when test='string-length(from/contact/@email) &gt; 0'>
										<nobr><xsl:value-of select="from/contact/@email"/></nobr>
									</xsl:when>
									<xsl:otherwise>
										Mittente sconosciuto
									</xsl:otherwise>
								</xsl:choose>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:otherwise>
				</xsl:choose>
			</TD>
			<TD width="1%" align="left" style="padding:2px; border-bottom: 1px solid #EBE9E4;" bgcolor="white">
				<xsl:choose>
					<xsl:when test='@hasAttachments = "True"'>
						<img src="/imgs/paperclip.gif"/>
					</xsl:when>
					<xsl:otherwise>
					&#160;
					</xsl:otherwise>
				</xsl:choose>
			</TD>
			<TD align="left" style="padding:2px; border-bottom: 1px solid #EBE9E4;" bgcolor="white">
				<xsl:choose>
					<xsl:when test="@read = 'True'">
						<a href="/mailbox/IM.mailbox.aspx?folder={/mailbox/@name}&amp;msgid={@msgid}">
							<xsl:apply-templates/>
						</a>
					</xsl:when>
					<xsl:otherwise>
						<b><a href="/mailbox/IM.mailbox.aspx?folder={/mailbox/@name}&amp;msgid={@msgid}">
							<xsl:apply-templates/>
						</a></b>
					</xsl:otherwise>
				</xsl:choose>
			</TD>
			<TD width="1%" align="left" style="padding:2px; border-bottom: 1px solid #EBE9E4; font-size:8pt;" bgcolor="white">
				<nobr>
				<xsl:value-of select="substring(@sortdatetime,9,2)"/>-<xsl:value-of select="substring(@sortdatetime,6,2)"/>-<xsl:value-of select="substring(@sortdatetime,1,4)"/>&#160;
				<xsl:value-of select="substring(@sortdatetime,12,8)"/>
				</nobr>
			</TD>
			<TD align="right" style="padding:2px; border-bottom: 1px solid #EBE9E4; font-size:8pt;" bgcolor="white">
				<xsl:choose>
					<xsl:when test="@size &lt; 1024">
						<div style="font-size:.8em;color:#666666;"><nobr>(<xsl:value-of select="@size"/> bytes)</nobr></div>
					</xsl:when>
					<xsl:when test="@size &lt; 1048576">
						<div style="font-size:.8em;color:#666666;"><nobr>(<xsl:value-of select="floor(@size div 1024)"/> kb)</nobr></div>
					</xsl:when>
					<xsl:when test="@size &gt;= 1048576">
						<div style="font-size:.8em;color:#666666;"><nobr>(<xsl:value-of select="floor(@size div 1048576)"/> mb)</nobr></div>
					</xsl:when>
				</xsl:choose>
			</TD>

			<TD width="8" background="/imgs/pvts/box-r.gif" bgcolor="white"><IMG height="10" src="/imgs/pvts/box-r.gif" width="8" border="0"/></TD>
		</TR>

	</xsl:when>
	<xsl:when test='/mailbox/@itype &lt;= 2'>

		<TR vAlign="top">
			<TD width="8" background="/imgs/pvts/box-l-back.gif" bgcolor="white"></TD>
			<TD width="1%" align="left" style="padding:2px; border-bottom: 1px solid #EBE9E4;" bgcolor="white">
				<input type="checkbox" name="deleteList" value="{@msgid}"/>
			</TD>
			<TD width="25px" height="35px" align="left" style="padding-top:5px; padding:2px; border-bottom: 1px solid #EBE9E4;" bgcolor="white">
				<xsl:choose>
					<xsl:when test='/mailbox/@name="INBOX.Sent" or /mailbox/@name="INBOX.Drafts"'>
						<xsl:choose>
							<xsl:when test='to/contact/@userid'>
								<nobr>
								<xsl:call-template name="user">
									<xsl:with-param name="status" select="to/contact/@status"/>
									<xsl:with-param name="sexid" select="to/contact/@sexid"/>
									<xsl:with-param name="certified" select="to/contact/@certified"/>
									<xsl:with-param name="userid" select="to/contact/@userid"/>
									<xsl:with-param name="nick" select="to/contact/@nick"/>
								</xsl:call-template>
								</nobr>
							</xsl:when>
							<xsl:otherwise>
								<nobr><xsl:value-of select="to/contact/@name"/></nobr><br/><span style="font-size:8pt;">&lt;<xsl:value-of select="to/contact/@email"/>&gt;</span>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:when>
					<xsl:otherwise>
						<xsl:choose>
							<xsl:when test='from/contact/@userid'>
								<nobr>
								<xsl:call-template name="user">
									<xsl:with-param name="status" select="from/contact/@status"/>
									<xsl:with-param name="sexid" select="from/contact/@sexid"/>
									<xsl:with-param name="certified" select="from/contact/@certified"/>
									<xsl:with-param name="userid" select="from/contact/@userid"/>
									<xsl:with-param name="nick" select="from/contact/@nick"/>
								</xsl:call-template>
								</nobr>
							</xsl:when>
							<xsl:otherwise>
								<nobr><xsl:value-of select="from/contact/@name"/></nobr><br/><span style="font-size:8pt;">&lt;<xsl:value-of select="from/contact/@email"/>&gt;</span>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:otherwise>
				</xsl:choose>
			</TD>
			<TD width="1%" align="left" style="padding:2px; border-bottom: 1px solid #EBE9E4;" bgcolor="white">
				<xsl:choose>
					<xsl:when test='@hasAttachments = "True"'>
						<img src="/imgs/paperclip.gif"/>
					</xsl:when>
					<xsl:otherwise>
					&#160;
					</xsl:otherwise>
				</xsl:choose>
			</TD>
			<TD width="100%" align="left" style="padding:2px; border-bottom: 1px solid #EBE9E4;" bgcolor="white">
				<xsl:choose>
					<xsl:when test='from/contact/@userid'>
						<xsl:choose>
							<xsl:when test="@read = 'True'">
								<a href="/mailbox/IM.mailbox.aspx?folder={/mailbox/@name}&amp;msgid={@msgid}">
									<xsl:apply-templates/>
								</a>
							</xsl:when>
							<xsl:otherwise>
								<b><a href="/mailbox/IM.mailbox.aspx?folder={/mailbox/@name}&amp;msgid={@msgid}">
									<xsl:apply-templates/>
								</a></b>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:when>
					<xsl:otherwise>
						<xsl:choose>
							<xsl:when test="@read = 'True'">
								<a href="/help/showError.aspx?error=1010">
									<xsl:apply-templates/>
								</a>
							</xsl:when>
							<xsl:otherwise>
								<b><a href="/help/showError.aspx?error=1010">
									<xsl:apply-templates/>
								</a></b>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:otherwise>
				</xsl:choose>
			</TD>
			<TD width="100%" align="left" style="padding:2px; border-bottom: 1px solid #EBE9E4; font-size:8pt;" bgcolor="white">
				<nobr>
				<xsl:value-of select="substring(@sortdatetime,9,2)"/>-<xsl:value-of select="substring(@sortdatetime,6,2)"/>-<xsl:value-of select="substring(@sortdatetime,1,4)"/>&#160;
				<xsl:value-of select="substring(@sortdatetime,12,8)"/>
				</nobr>
			</TD>
			<TD width="100%" align="right" style="padding:2px; border-bottom: 1px solid #EBE9E4; font-size:8pt;" bgcolor="white">
				<xsl:choose>
					<xsl:when test="@size &lt; 1024">
						<div style="font-size:.8em;color:#666666;"><nobr>(<xsl:value-of select="@size"/> bytes)</nobr></div>
					</xsl:when>
					<xsl:when test="@size &lt; 1048576">
						<div style="font-size:.8em;color:#666666;"><nobr>(<xsl:value-of select="floor(@size div 1024)"/> kb)</nobr></div>
					</xsl:when>
					<xsl:when test="@size &gt;= 1048576">
						<div style="font-size:.8em;color:#666666;"><nobr>(<xsl:value-of select="floor(@size div 1048576)"/> mb)</nobr></div>
					</xsl:when>
				</xsl:choose>
			</TD>

			<TD width="8" background="/imgs/pvts/box-r.gif" bgcolor="white"><IMG height="10" src="/imgs/pvts/box-r.gif" width="8" border="0"/></TD>
		</TR>

	</xsl:when>
</xsl:choose>

</xsl:for-each>

		<TR vAlign="top">
			<TD width="8" background="/imgs/pvts/box-l-back.gif" bgcolor="white"></TD>
			<TD width="100%" colspan="6" align="center" valign="middle" style="height:3em; margin-top:10px; padding:2px; border-top: 1px solid #000000;" bgcolor="white">
				<xsl:choose>
					<xsl:when test="(@totmsg &lt;= 15)">
						<xsl:call-template name="im.mailbox.page">
							<xsl:with-param name="page" 		select="@page"/>
							<xsl:with-param name="nrpages" 	select="1"/>
							<xsl:with-param name="counter" 	select="1"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="(@totmsg &gt; 15)">
						<xsl:call-template name="im.mailbox.page">
							<xsl:with-param name="page" 		select="@page"/>
							<xsl:with-param name="nrpages" 	select="floor( @totmsg div 15 ) + 1"/>
							<xsl:with-param name="counter" 	select="1"/>
						</xsl:call-template>
					</xsl:when>
				</xsl:choose>
			</TD>
			<TD width="8" background="/imgs/pvts/box-r.gif" bgcolor="white"><IMG height="10" src="/imgs/pvts/box-r.gif" width="8" border="0"/></TD>
		</TR>

		<TR>
			<TD width="8"><IMG height="8" src="/imgs/pvts/box-bl.gif" width="8" border="0"/></TD>
			<TD width="100%" colspan="6" background="/imgs/pvts/box-b.gif" bgcolor="white"><IMG height="8" src="/imgs/pvts/box-b.gif" width="10" border="0"/></TD>
			<TD width="8"><IMG height="8" src="/imgs/pvts/box-br.gif" width="8" border="0"/></TD>
		</TR>
	</TBODY>
</form>
</TABLE>

</xsl:template>

</xsl:stylesheet>